/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-10-14 09:00:55
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-10-16 11:30:52
 * @FilePath: \adminstration\src\Common\Modal\TwoModalList\EnterpriseFiles.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../Api/Api'
import { BuiltInData } from '../config'
import { TwoAddBtn, ThrDeleteBtn, SeeEnclosure } from '../options'

// enterpriseFileCategory

export const EnterpriseFiles = async ({ upDataEvent, data }) => {
    let dataList = {
        type: '企业文件管理',
        // hideInSearch: true,
        pageSize: 10,
        params: {},
        classification: 'TableModal',
        get: API_LIST([data.uuid])['getEnterpriseEnterpriseFiles'],
        options: [
            <TwoAddBtn
                upDataEvent={upDataEvent}
                title="添加文件信息"
                ThrKey="ThrModal"
                value="EnterpriseFiles"
                data={data}
            />,
        ],
        columns: [
            {
                dataIndex: 'tableName',
                title: '文件标题',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'enterpriseFileCategory',
                title: '文件类型',
                valueType: 'select',
                valueEnum: BuiltInData.enterpriseFileCategory,
                rules: true,
                width: 350,
                className: 'RemarkForm',
            },
            {
                title: '创建时间',
                dataIndex: 'createTime',
                valueType: 'input',
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 300,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { attachment, uuid, coverAttachment } = record
                    return [
                        attachment?.fileUrl && (
                            <SeeEnclosure
                                key="seeFile"
                                title="查看附件"
                                data={{
                                    className: 'Admin',
                                    url: attachment.fileUrl,
                                }}
                            />
                        ),
                        coverAttachment?.fileUrl && (
                            <SeeEnclosure
                                key="seeCover"
                                title="查看封面"
                                data={{
                                    className: 'Admin',
                                    url: coverAttachment.fileUrl,
                                }}
                            />
                        ),
                        <ThrDeleteBtn
                            key="delete"
                            additional={[uuid]}
                            record={data.uuid}
                            upDataEvent={upDataEvent}
                            data={{ key: 'delete', url: 'delEnterpriseEnterpriseFiles', title: '删除样品附件' }}
                        />,
                    ]
                },
            },
        ],
    }

    return dataList
}
